var mapIds = [993000650];
var 准备地图 = 993000601;

function init() {}

function setup(c, a) {
    em.setProperty("state", 1);
    em.setProperty("leader", "true");
    var c = em.newInstance("活动_暴风之翼狩猎");
    for (var b = 0; b < mapIds.length; b++) {
        var d = c.setInstanceMap(mapIds[b]);
        d.resetFully();
        d.killAllMonsters(false)
    }
    c.schedule("暴风之翼", 0);
    c.schedule("刷怪", 0);
    return c
}

function 暴风之翼(a) {
    var b = a.getMapInstance(0);
    if (b.countMonsterById(9832001) == 0) {
        switch (a.rand(1, 4)) {
            case 1:
                b.spawnMonsterOnGroundBelow(em.getMonster(9832001), new java.awt.Point(-766, -296));
                break;
            case 2:
                b.spawnMonsterOnGroundBelow(em.getMonster(9832001), new java.awt.Point(-991, -347));
                break;
            case 3:
                b.spawnMonsterOnGroundBelow(em.getMonster(9832001), new java.awt.Point(-835, -543));
                break;
            case 4:
                b.spawnMonsterOnGroundBelow(em.getMonster(9832001), new java.awt.Point(-643, -771));
                break
        }
        a.schedule("暴风之翼", 10 * 1000)
    } else {
        a.schedule("暴风之翼", a.rand(10, 15) * 1000)
    }
}
var mobs = [9832002, 9832003, 9832004, 9832005, 9832010, 9832011, 9832012, 9832013, 9832014, 9832015, 9832016, 9832017, 9832018, 9832019, 9832020, 9832021, 9832022];

function 刷怪(b) {
    var d = b.getMapInstance(0);
    if (d.getNumMonsters() < 50) {
        var c = b.rand(10, 20);
        for (var a = 0; a < c; a++) {
            d.spawnMonsterOnGroundBelow(em.getMonster(b.randArray(mobs, 1)[0]), d.getRandomFinePosition())
        }
    }
    b.schedule("刷怪", 10 * 1000)
}

function onPlayerRegistered(b, a) {
    a.setReviveCount(-100);
    var c = b.getMapInstance(0);
    a.changeMap(c, c.getPortal(0));
    b.startEventTimer(30 * 1000)
}

function onPlayerRevived(b, a) {
    return false
}

function onMapChanged(c, b, a) {
    if (mapIds.indexOf(a) < 0) {
        on玩家退场(c, b, false);
        return
    }
    em.setProperty("kill", "0");
    em.setProperty("clear", "0");
    em.setProperty("curMap", a)
}

function onPlayerDisconnected(b, a) {
    on玩家退场(b, a, false);
    return 0
}

function onMonsterDamaged(b, a, d, e, c) {}

function onTimeOut(a) {
    a.getPlayers().forEach(function (b) {
        on玩家退场(a, b, true)
    })
}

function onMonsterKilled(a, b) {
    player.getAPI().addNumberForQuestCustomData(9930001, 1);
    if (b == 9832001) {
        a.startEventTimer(a.getTimeLeft() + 6 * 1000);
        player.getAPI().getMap().startSimpleMapEffect("暴风之翼消灭掉了。可以再多停留一段时间了！", 5120159);
        player.getAPI().fieldEffect_ScreenMsg("PoloFritto/bonus");
        player.getAPI().fieldEffect_PlayFieldSound("Romio/discovery", 100)
    }
    return 1
}

function onPartyDisbanded(a) {}

function onPlayerKilled(b, a) {}
var setupTask;

function randomNum(b, a) {
    switch (arguments.length) {
        case 1:
            return parseInt(Math.random() * b + 1, 10);
            break;
        case 2:
            return parseInt(Math.random() * (a - b + 1) + b, 10);
            break;
        default:
            return 0;
            break
    }
}

function initProp(a, b) {
    if (em.getProperty(a) == null) {
        em.setProperty(a, b)
    }
}

function initPropArray(a, d, c, e) {
    for (var b = c; b <= e; b++) {
        if (em.getProperty(a + "_" + b) == null) {
            em.setProperty(a + "_" + b, d)
        }
    }
}

function on玩家退场(c, b, a) {
    if (b.getQuestStatus(16406) == 1) {
        b.getAPI().addNumberForQuestInfo(16406, "count", 1)
    }
    if (b.getQuestStatus(16407) == 1) {
        b.getAPI().addNumberForQuestInfo(16407, "count", 1)
    }
    c.disposeIfPlayerBelow(a ? 999 : 0, 准备地图);
    em.getProperties().clear();
    em.setProperty("state", 0);
    em.setProperty("leader", "true");
    c.unregisterPlayer(b)
}

function onItemPickedUp(b, a, c) {};